home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: Specifying a Member Function Address For WNDCLASS Structure
- Date: 23 Feb 1996 00:04:19 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4gj0a3$gac@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe4.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Feb 22, 1996 05:16:04 in article <Specifying a Member Function Address
- For WNDCLASS Structure>, 'yatesc@csee.usf.edu (Randy Yates)' wrote:
-
-
- >Hello,
- >
- >I'm writing a MS-Windows 3.1 program and I'd like to have the
- >message processing procedure for the window class be a member
- >function, but Borland C++ 4.0 complains with a
- >
- >Error GAMECON.CPP 25: Cannot convert 'long (pascal
- GameControl::*)(unsigned
- >int,unsigned int,unsigned
- >int,long)' to 'long (pascal *)(unsigned int,unsigned int,unsigned
- int,long)'
- >
- You can't -- unless the member function is static. But, since
- a static member function is functionally more like an ordinary
- procedure than a real member function, IMHO there's not much
- point in it.
-
- Declare your window procedure as an ordinary function, then
- figure out how to compute the object it applies to, and
- then call the appropriate member function.
-
- In some cases, the message or the window can contain the
- object pointer. One such case is when there's a one-to-
- one correspondence between a window and a class
- instance.
-
- For example:
-
- int CALLBACK MyWndProc (HWND hw, UINT msg,
- WPARAM wp, LPARAM lp)
- {
- MyClass * p = (MyClass*)::GetWindowLong(hw, .....);
- p->ProcessMessage(msg, wp, lp);
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-